package com.example.serviceconsumer.client;

import com.example.serviceconsumer.fallback.ProductClientBFallback;
import com.example.serviceconsumer.model.Product;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;

// 使用断路器 backendB，并指定 fallback 类
@FeignClient(value = "service-providerB", path = "/products", fallback = ProductClientBFallback.class)
public interface ProductClientB {

    @GetMapping("/{id}")
    ResponseEntity<Product> getProductById(@PathVariable("id") Long id);

    @PutMapping("/{id}")
    ResponseEntity<Product> updateProduct(@PathVariable("id") Long id, @RequestBody Product product);
}